import { defineStore } from 'pinia'
import pinia from './pinia.js'
const useStore = defineStore('app', {
  id: 'app',
  state() {
    return {
      a: 1,
      b: 2,
      routePosition: {},
      price: 9.21,
      priceEnd: 30
    }
  },
  actions: {
    add() {
      this.a++
    },
    getRoutePosition(route) {
      let { fullPath } = route
      let position = this.routePosition[fullPath] || 0
      return position
    },
    saveRoutePosition(route, position) {
      let { fullPath } = route
      this.routePosition[fullPath] = position
    },
    clearRoutePosition() {
      this.routePosition = {}
    }
  },
  persist: true
})
export default useStore(pinia)
